<template>
	<view class="mainpadding2">
		<view class="mainpadding_top flexbetween ffffff radius" v-for="item in list.data" :key="item.id">
			<view class="flexleft">
				<image :src="item.user.avatar_text" mode="" class="headimg margin_right2"></image>
				<view class="">
					<view class="titletext xiaohei bold">{{item.user.nickname}}</view>
					<view class="smalltext xiaohong margin_top1" style="text-decoration: underline;" @click="jumpdetail(item.id)">余额：{{item.money}}</view>
					<view class="smalltext xiaolv bold margin_top1" style="text-decoration: underline;" @click="callphone(item.user.mobile)">电话：{{item.user.mobile}}</view>
				</view>
			</view>
			<view class="lvbtn margin_left" @click="show=true;currentmsg=item;">修改余额</view>
		</view>
		<u-modal :show="show" title="增加/减少余额" confirmText="确认" @confirm="shenhe" cancelText="取消" @cancel="show=false"
			showCancelButton>
			<view class="slot-content" style="width: 600rpx;">
				<view class="flexbetween margin_top">
					<view class="main_size bold hei_text" style="min-width: 120rpx;">余额：</view>
					<view class="flexright">
						<view class="" style="min-width: 120rpx;max-width: 120rpx;">
							<view :class="isfu?'lvbtn2':'huibtn'" @click="isfu=!isfu">负数</view>
						</view>
						<input type="digit" class="textright" placeholder="请输入" v-model="money"/>
					</view>
				</view>
				<view class="textcenter margin_top smalltext xiaohui" v-if="isfu">注：点击负数按钮后输入的数字在提交的时候将会自动转为负数</view>
			</view>
		</u-modal>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				money:"",
				show:false,
				currentmsg:"",
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				user_zbfapply_listid: "",
				isfu:false
				
			}
		},
		onLoad(options) {
			this.user_zbfapply_listid = options.user_zbfapply_listid
		},
		onShow() {
			this.init()
		},
		methods: {
			jumpdetail(id){
				uni.navigateTo({
					url:"/pages_mypage/huiyuanyejl?id="+id+"&user_zbfapply_listid="+this.user_zbfapply_listid
				})
			},
			shenhe() {
				if(this.money===""){
					httpRequest.toast("请输入余额")
					return false
				}
				httpRequest.request("/api/user/editUserHyCardMoney", 'GET', {
					id: this.currentmsg.id,
					money: this.isfu?"-"+this.money:this.money
				}).then(res => {
					this.show = false
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						this.init()
					}
				})
			},
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
					user_zbfapply_id:this.user_zbfapply_listid
				}
				let url = '/api/user/getCgUserHycard'
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
					console.log(this.list, "金戈里");
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.huibtn {
		background: #F9F9F9;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		padding: 15rpx 30rpx;
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #777777;
	}
	
	.lvbtn2 {
		background: rgba(255, 0, 0,.1);
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		padding: 15rpx 30rpx;
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #ff0000;
	}
	.headimg{
		width: 100rpx;
		height: 100rpx;
		min-width: 100rpx;
		border-radius: 50%;
	}
</style>
